<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="x-rim-auto-match" content="none"> 
<link href="${ctx}/resources/semanticui/semantic.min.css"
	rel="stylesheet" type="text/css" />
<link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/resources/swiper-3.4.2.min.css" rel="stylesheet" type="text/css" />
<title>咨询详细信息</title>
<style>
.swiper-container {
    width: 100%;
    height: auto;
}   
.ui.button, .ui.buttons .button, .ui.buttons .or {
    font-size: 16px;
}
</style>
</head>
<body>
<c:choose>
<c:when test="${order!=null}">
<input type="hidden" name="orderId" id="orderId" value="${order.id}" />
 <input id="money" type="hidden" value="${order.payMoney}">
	<div style="text-align:left;">
		<div class="ui leaderboard test ad" data-text="✔&nbsp;&nbsp;${order.statusName}" style="width:100%;background-color:#152b52;font-size:16px;"></div>
		<div style="padding-left:1rem;padding-top:1rem;">
			<h5 class="ui header">${order.orderdesc}</h5>
			<div>
				<p class="list_content content">预约时间：<span  style="font-weight: bold;color: red;">${order.orderTime}</span></p>
				<c:choose>
					<c:when test="${order.status==0 ||order.status==4||order.status==5}">
						<input type="hidden" value="${appUser.phone}" id="appphone" name="appphone">
						<p class="list_content content">联&nbsp;&nbsp;系&nbsp;&nbsp;人：&nbsp;&nbsp;<label id="phone"></label></p>
					</c:when>
					<c:otherwise>
						<a class="position" data-position-id="${appUser.phone}"><p class="list_content content">联&nbsp;&nbsp;系&nbsp;&nbsp;人：&nbsp;&nbsp;${(appUser.phone).substring(0,7)}****&nbsp;&nbsp; 点击查看基本信息</p></a>
					</c:otherwise>
				</c:choose>
				<hr class="hrtext"/>
			</div>
		
			<div>
				<p class="list_content content">订单编号：YQS${order.ordercode}</p>
				<p class="list_content content">下单时间：${order.createTime}</p>
				<p class="list_content content">订单总价：${order.orderMoney}元</p>
				<p class="list_content content">实付金额：<span id="price"></span>元</p>
<%--				<p class="list_content content">超出用时：${order.priceDiffTime}分钟</p>
				<p class="list_content content">需补余款：${order.payDiffMoney}元</p>--%>
				<hr class="hrtext"/>
			</div>
			<c:if test="${not empty eva}">
			<div>
				<p class="list_content content">我收到的评价</p>
				<h5 class="list_title">
					${eva.buyerName}<span style="color:#F47e2d;float:right;margin-right:20px;">对您的评分：${eva.buyerEvalScore }分
				</span>
				</h5>
				<p class="list_content content">${eva.buyerEvalContent }</p>
				<p class="list_content content" >咨询项目：${eva.orderdescIds}</p>
				<%-- <p class="list_content content">
					订单号：YQS${eva.orderCode}
				</p> --%>
			</div>
			</c:if>
		</div>
		<c:if test="${order.status==0}">
	    <div class="ui center aligned segment" id="choice-buttons" > 
	        <div class="two ui buttons" style="width:90%;font-size:16px;"> 
	            <div class="ui button active dog" id="accept" style="padding-top:1.4rem;padding-bottom:1.4rem;">接单</div> 
	            <div class="ui button active dog" id="refuse" style="padding-top:1.4rem;padding-bottom:1.4rem;">拒单</div> 
	        </div>
	    </div>
	    </c:if>

	</div>

</c:when>
<c:otherwise>
<div class="ui segment">
	此订单已清理!
</div>

</c:otherwise>
</c:choose>
<c:if test="${order.status !=0 && order.status !=4 && order.status != 5 && order.status != 6}">
	<div style="text-align: right;right: 1px;">
		<c:set var="tag" value="${orderDesc.tag}"/>
		<c:choose>
			<c:when test="${fn:indexOf(tag,'简历修改')!='-1'}">
				<a  href="${ctx}/wechat/order/toOrdetailResume.do?orderId=${order.id}">补充资料详情</a>
			</c:when>
			<c:when test="${fn:indexOf(tag,'面试辅导')!='-1'}">
				<a href="${ctx}/wechat/order/toOrdetailInterview.do?orderId=${order.id}">补充资料详情</a>
			</c:when>
			<c:when test="${fn:indexOf(tag,'薪酬分析')!='-1'}">
				<a  href="${ctx}/wechat/order/toOrdetailSalary.do?orderId=${order.id}">补充资料详情</a>
			</c:when>
			<c:when test="${fn:indexOf(tag,'职业规划')!='-1'}">
				<a  href="${ctx}/wechat/order/toOrdetailPlan.do?orderId=${order.id}">补充资料详情</a>
			</c:when>
			<c:when test="${fn:indexOf(tag,'离职咨询')!='-1'}">
				<a  href="${ctx}/wechat/order/toOrdetailLeave.do?orderId=${order.id}">补充资料详情</a>
			</c:when>
		</c:choose>

	</div>
</c:if>

	<script src="${ctx}/resources/jweixin-1.0.0.js"></script>
	<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
	<script type="text/javascript">

wx.config({
    debug: false, 
    appId: "${config.appid}",  
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'showOptionMenu']  
});

    var handler = { 
        activate: function() { 
            $(this).addClass('active').siblings().removeClass('active'); 

            if($(this).attr('id') == 'accept') {
              var orderId  = $("#orderId").val();
              console.log(orderId);
              var postUrl = '${ctx}/wechat/hunter/updOrder.do';
              $.ajax({ 
                  url: postUrl, 
                  type: "POST", 
                  data: {orderId:orderId,status:1},
                  success: function(data, status){
                      if (data.errorcode == 0){
                    	  alert(data.msg);
                    	  var forwardUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+ orderId;
                    	  window.location.href=forwardUrl+'&v='+Math.random();
                          //window.location.href = forwardUrl;
                      }else{
                          alert(data.msg);
                          $(this).removeClass('disabled');
                      }
                  }, 
                  error: function(){ 
                      alert("服务出错，请稍后尝试"); 
                      $(this).removeClass('disabled');
                  } 
              });
            }
            if($(this).attr('id') == 'refuse') {
                var orderId  = $("#orderId").val();
                console.log(orderId);
                var postUrl = '${ctx}/wechat/hunter/updOrder.do';
                $.ajax({ 
                    url: postUrl, 
                    type: "POST", 
                    data: {orderId:orderId,status:5},
                    success: function(data, status){
                        if (data.errorcode == 0){
                      	  	alert(data.msg);
                            var forwardUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+ orderId;
                            window.location.href=forwardUrl+'&v='+Math.random();
                        }
                      /*   else{
                            alert(data.msg);
                            $(this).removeClass('disabled');
                        } */
                    }, 
                  /*   error: function(){ 
                        alert("服务出错，请稍后尝试"); 
                        $(this).removeClass('disabled');
                    }  */
                });
         	 }
            
            if($(this).attr('id') == 'callphone') {
                var orderId  = $("#orderId").val();
                console.log(orderId);
                var postUrl = '${ctx}/wechat/order/callPhone.do';
                <%--$.ajax({ --%>
                <%--    url: postUrl, --%>
                <%--    type: "POST", --%>
                <%--    data: {orderId:orderId},--%>
                <%--    success: function(data, status){--%>
                <%--        if (data.errorcode == 0){--%>
                <%--      	  	alert(data.msg);--%>
                <%--            var forwardUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+ orderId;--%>
                <%--            window.location.href=forwardUrl+'&v='+Math.random();--%>
                <%--        }else{--%>
                <%--            alert(data.msg);--%>
                <%--            $(this).removeClass('disabled');--%>
                <%--        }--%>
                <%--    }, --%>
                <%--    error: function(){ --%>
                <%--        alert("服务出错，请稍后尝试"); --%>
                <%--        $(this).removeClass('disabled');--%>
                <%--    } --%>
                <%--});--%>
         	 }
        } 
    };


    $(document).ready(function() { 
    	//total_fee
    	var total_fee = $("#money").val();
    	$("#price").html(total_fee*0.01);
    	
    	//phone
    	var phone=$("#appphone").val();
    	if (typeof phone != "undefined") {    
	    	var mphone=phone.substr(0, 3) + '****' + phone.substr(7);
	    	$("#phone").text(mphone);
    	}
    	
    	
         $('.button').on('click', handler.activate);

         $('.position').on('click', function() {
             var mobile = $(this).attr('data-position-id');
             var getUrl = '${ctx}/wechat/hunter/toViewCandidate.do?mobile='+mobile;
             location.href = getUrl;
         });
    });

</script>
  
</body>
</html>